<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [1, 2, 3, 4, 5, 6, 7]

      
            var a = arr[0], c = arr[0]
            for (var j = 0; j <= arr.length; j++) {
                var b = arr[j]
                if (a <= b) {
                    a = b
                }
                if (c >= b) {
                    c = b
                }
            }


      
        console.log(a,c)


    </script>
</body>

</html>